<?php
namespace yan\googlebusiness;

abstract class AbstractFactory{
    private static $_instance = [];
    private $_service;
    public function __construct($service)
    {
        $this->_service = $service;
    }
    public static function instance($service, $flag = false){
        $className = get_called_class();
        if(empty(self::$_instance[$className]) || $flag){
            self::$_instance[$className] = new $className($service);
        }
        return self::$_instance[$className];
    }
    public function getService(){
        return $this->_service;
    }
}